package org.minuframework.file.read;

import javax.servlet.http.HttpServletResponse;

import org.minuframework.core.ApplicationConfigurer;
import org.minuframework.exception.ExceptionFailed;
import org.minuframework.file.upload.FileParamerConfigurer;
import org.minuframework.file.upload.FileTypesConfigurer;
import org.minuframework.file.upload.FileUploadType;

@Deprecated
public class FileRead extends DefaultFileRead{
    
    public FileRead(FileParamerConfigurer fileParamerConfigurer, FileTypesConfigurer fileTypesConfigurer, String charset){
        super(fileParamerConfigurer, fileTypesConfigurer, charset);
    }
    
    // ------------------------------------------------------------------------
    
    public static boolean picReader(String fileName, HttpServletResponse response, FileUploadType type) throws ExceptionFailed{
        return new FileReadBuilder().setCharset(ApplicationConfigurer.DEFAULE_MINU_CHARSET).create()
                .picRead(fileName, response, type);
    }
    
    public static boolean picReaderSafe(String fileName, HttpServletResponse response, FileUploadType type){
        try {
            return picReader(fileName, response, type);
        } catch (ExceptionFailed e) {}
        
        return false;
    }
    
    public static boolean picReader(String fileName, HttpServletResponse response, String type) throws ExceptionFailed{
        return new FileReadBuilder().setCharset(ApplicationConfigurer.DEFAULE_MINU_CHARSET).create()
                .picRead(fileName, response, type);
    }
    
    public static boolean picReaderSafe(String fileName, HttpServletResponse response, String type){
        try {
            return picReader(fileName, response, type);
        } catch (ExceptionFailed e) {}
        
        return false;
    }
    
}
